package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class POSIDEFactory extends AbstractTokenVisitorFactory {

	private static POSIDEFactory INSTANCE;
	
	private ARRAYFactory arrayFactory;
	private PARENTESISFactory parentesisFactory;

	
	public static POSIDEFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new POSIDEFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			arrayFactory = ARRAYFactory.getInstance();
			parentesisFactory = PARENTESISFactory.getInstance();
		}
	};
	
	private POSIDEFactory() throws Exception {

	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		initializer.init();

		return arrayFactory.makeChainedVisitor(parentesisFactory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();

		return arrayFactory.makeChainedVisitor(parentesisFactory.makeVisitor());
	}
	
	
}
